package com.market.manager.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.market.dao.ProductThemeDao;
import com.market.domain.Product;
import com.market.domain.ProductTheme;
import com.market.manager.ProductThemeManager;

@Service("productThemeManager")
public class ProductThemeManagerImpl extends GenericManagerImpl<ProductThemeDao, ProductTheme, Long>
		implements ProductThemeManager {
	
	
	@Autowired
	@Override
	public void setDao(ProductThemeDao dao) {
		this.dao = dao;		
	}

	public ProductTheme fetchOne(Long id) {
		ProductTheme productTheme = super.fetchOne(id);
		productTheme.setProducts(this.fetchProducts(productTheme));
		return productTheme;
	}

	public ProductTheme fetchOne(ProductTheme productTheme) {
		return this.fetchOne(productTheme.getId());
	}

	

	public List<Product> fetchProducts(ProductTheme productTheme) {
		return this.dao.findProducts(productTheme);
	}

	public List<ProductTheme> fetchActiveProductThemes() {
		return this.dao.findActiveProductThemes();
	}
	
}
